Fixed several issues around establishing connections, etc.