More restructuring and learning of the code