Did a huge cleanup of the code