optimization and rewrite rules questions