Refactored a lot of stuff.
Merge pull request #370 from iameric1986/master

Refactored a lot of stuff.