Handle no availability and explicitly reset $avail internal pionter
Merge branch 'master' into javascript-porting