Some OptionalConnection work.

Deprecate getConnection, fix CustomWindow's getOptionalConnection
returning null, change a couple of usages.