Gamma ray imaging probes. 2: Code optimization