Enhanced the codebase

Enhanced the codebase and breakdown reusable code into modules.