Moved some useful methods into their own class.