Many small bug fixes.