some cleanup and minor changes on the main file