small bug fixes and minor improvements