Remove copied code

...and call the private functions directly by accessing their vars. This still has the problem of relying on private code, but at least there is on need to keep both copies in sync.