optimizations and debug statements