cleanup and optimize

simplified code, did some up front optimization and made choice of array
color by programmable