much refactored code for async connection to indx - it seems to work, but needs more testing