Move opened and docked into seperated functions.  var fix
Merge pull request #3 from zackbloom/master

Fix var, separate functions.