Switches to toplevel objects with public/private members

Fixes #1002247