Fixing code smells and cleaning up the code