clean up and small bug fixes