Rearranged program structure and added main classes