Clean up code and add copyright to files