fix optimizations. improve consistency