Fixed a bunch of stuff now that I'm using it for real. Added template controller