Cleaning up core parts of the code