various small bug fixes