170/variable complete

Makes progress on https://github.com/backdrop/backdrop-issues/issues/170
Fixes https://github.com/backdrop/backdrop-issues/issues/410.

These two are combined because https://github.com/backdrop/backdrop-issues/issues/170 depends on https://github.com/backdrop/backdrop-issues/issues/410. Converting some of the variables to state resulted in an infinite loop when clearing the page cache.