Restructure MAIN source file