Feature/refactor

@sneal , @dvanbuskirk Refactored.
This is really hard to parse