Speedup and clean up operation optimization.
Merge pull request #306 from prometheus/refactor/optimize-ops

Speedup and clean up operation optimization.