Serious Refactoring

So much code...I should sleep.