Refactored back end into multiple files