Changes for prod and dev environments. Some optimizations for removing
extra loop.