small bug fixes, cleanup