Fix magnitude error in grade calculation.
This resolves #1.