Create functions.lib

Main support functions moved to functions.lib