Cleaning up code to get rid of errors