Refactoring

I've removed a lot of redundancy.