Refactors router into state manager

I'm not really sure how I feel about this.. I'll look it over in the morning

Any suggestions are welcome