fixed math bugs
Merge pull request #26 from dwetterau/master

Fixed small mathematical errors.