Fixed small bug and some warnings.