Reformatted some functions to be cleaner