Code layout fixes and cleanup