Address code review: improve concurrency resilience of getCode()