Refactored into lib folder.