Refactored some more and really managed to reduce the amount of code.