Adding State and missing functions for cleanup and reconnect