As mentioned this file still needs refactoring.