Fix problems encountered by testing