Finished Refactoring and fixing

Everyhting is fixed as far as i can tell. I'm now preparing it for testing, but due to concerns aobut how long some things have taken I'm going to run it through some profiling tools first.

Refs #7865