Did some modifications to prevent failing on glitches caused by slow connection.