more optimizations: programming time down to 3 seconds