Feature/refactor

@sneal , @dvanbuskirk Refactored.