Cppcheck support

Cppcheck is supported, and produces a clean output.
- empty() method added for emptiness check
- some minor bug fixing