Convert to using proper javascript class, public private methods etc etc