This block is largely a copy, with `self` replacing `layer` and `Core.` removed.