Hard-coded timeouts removed or replaced

Such as sleep(..). Also some blocks replaced by status verification and other suitable methods.