Refactored core functionality into separate module