fix warnings and minor bug