Several small bug fixes.