Some cleanup and a small bug fix.