Refactored code to multiple files.