Fixes variable names in calculations, closes #289