Fix ood checking

Rebased version of Ian's branch