Bunches of probably broken code while I figure things out.