Optimization improvements (issue #2)