many small bug fixes