Remove unneeded variables and improve the sizes calculation
Add margins