Iazel hmt and is valid fixes

Rebased version of #303