Move opened and docked into seperated functions.  var fix