Moved library functions to lib folder