Improve validation macro so it doesn't require caching instances

Hi, we have been using a modified version of the macro that doesn't require caching for some time, so I figured I'd submit it here.