Refactored core modules. Added documentation