Corpus-Driven Systems for Program Synthesis and Refactoring