Multiple small bug fixes