Avoid repeatedly checking validity of formula classes

We only need to check this once, when the class is initially loaded, not
every time an instance of the class is created.
Rewrite conditional with positive case first