Refactoring this file a bit to allow for easier move.