added static code analysis
added tests
misc fixes/updates