Fixed logic for overriding layouts within templates.