Code cleanup

I decided to refactor and cleanup some of the stuff so it's more legible and makes more sense. I think I stumbled on an Angular bug so I'll go ahead and test that out in Plunker and possibly submit it.