Yet another fix for issue #29

Fixed two bugs which cause the round-off errors.