Some small bug fixing