Fix automargin functionality