Very large AC update

Rewrite and optimization