minor bug fixes

stuff picked up by gdb