Some small bug fixes