Cleaned up layout code to fix height resizing