Bugfix: Calculations causing "nan"s were corrected.