Clean up InitStation and make GetDockingClearance cope with ships that are undocking

For #2242.

Includes a merge with master. These additions build ok (on Linux) but I haven't tested them *at all* yet, so beware.