A few small bug fixes