As this has been throughly tested, merging this for now. Will add an issue to refactor.