fix bugs (including bad formhash caclulcation bug).
also changes to debug output.