Moved some functions to extern lib