Instrument TopLevel's output() with a sanity check
While ideally we shouldn't have issues with pointer management, programmers are human and can make mistakes, so instrumenting output() to enforce the invariant of output() always returning a valid output helps avoid crashes now and potential crashes in the future from invariants being violated.