Refactored into lib and added composer file