Merge pull request #916 from FHenry/3.3

Fix margin calculation problem
Fix: regression