Lots of refactoring! Made things easier to read/understand (hopefully)