Add state filtering. Issue: #370