Reordered files + fixed small issues in the main code.