Cleaning up some functions