Make server, namespace and username optional.
Eliminate duplicate code.