Multiple changes for a common purpose:

Removed the unnecessary no_z array.
Test for non-zero states before invoking rules
Remove the unnecessary tail array