Refactors margin and padding transformers to dry up code