Corrected scan indexing
Corrected scan indexing. Added handling for connection loss. Fixed bugs causing window to freeze