Fix for rule application. This might still be broken, but this gets it working for now