Layout fixes and code cleanup