fix many tiny bugs