code quality improvements, fix bugs introduced by PR, fix tests
Merge pull request #7 from Srirangan/code_cleanup

code quality improvements, fix bugs introduced by PR, fix tests