Finished cleaning up the code