fixed npe when closing owner connection. Move the owner connection to a ...

...seperate class so that seperation is more clear. Added a few javadocs.
fixes #3169.