cleaned up a bit, but now I think I'm gonna rewrite most of the back end :/