Moved library code to lib folder