fix bugs and warningns.