Refactoring and calculation errors (ffod) fixed.