Refactor main file.