Remove temp files and some refactoring.