Added activity sleep before clearing activity cache (copied from @mrvisser.)