Added trojan cache writing logic