better error handling
some refactoring to make the auto connect into our core.