fix code analysis warnings, record time stats better