Moved some functions into commonmod