Got rid of mixed declarations and code in the main files