Fixed race condition with connection and socket initialization.
Added spinner.