Optimized EditSession.countBlocks.

Also fixed the questionable semantics for that anonymous class' "contains" method.