Fixed: Some bugs and probably introduced twice as many in the process.