Fix a couple of minor bugs that can cause NaN values
Merge pull request #1 from connec/minor_fixes

Fix a couple of minor bugs that can cause NaN values