Removes lots of duplicated code.
Instead of using type unsafe properties passed to the connect() call, we build a new object which does the handling of the properties to be passed.