Fixed some bugs in the docking code.