Do filter rewriting and numerous fixes