Fix problems found by tests