Switch to portable R6 classes

Essentially the issue is that we cannot say self$private
any more, and need to pass private to external functions.