Moved some cache cleaning/updating methods around to avoid what might be a replication lag issue I'm seeing on a site running this code.