many compatibility fixes. replaced offset() with wait().