Refactor code and rename files