RED-36520 Updated to use faster data structures