Moved some helper functions.