nit: it's my personal style preference, but I much prefer `instance != null ? instance : result.newModule()` rather than the flipped case you have here.