Started cleaning up some functions