Partial rule ported.

perf branch is now complete. Some cleanup required.