Add support for margins, borders, and padding
More fixes to layout code