Cleaned the code and made some file arrangements