Refactor

Refactored code for more awesomeness, clarity of vision and future extendability. Also sanity.