Moved some functions into shared