Various fixes pointed out by tests.