Fixed handling of top and bottom padding properly.