Rewrite as a separate layer