Moved some functions around