Added missing include which was left out in a previous minor refactor.
Moved certain functions to proper locations and added new source files for minor refactoring.