misc fixes.
Merge pull request #16 from frapposelli/refactoring_and_misc_fixes

misc fixes.