Redid a lot of code to work better

Basically a bunch of misc changes