Split build into files, got rid of chdir [close #1]