Move some functions into their own class