Refactored classes into modules for more flexible implementation