Cleaning up code and integrating