Moved around some functions