refactored and documented class JsGate.