Hacks I made to get this to run in way we needed it. Should be cleaned up.