several small bug fixes.