Reduced code duplication with extraction of penalty.
Merge pull request #33 from Tillsten/master

Refactor out penalty for scalar minimizers