Debugging and optimization