Refactor filenames, and clean up some code