Add control caching

Bring in @haus's speedups into master.