small bug fixes in a few places