Moved some functions into their own modules