Finish work on RECORD_DELETE and bugfix a couple of loop conditions