Identity cache

Fixes a small issue with blank values, similarly to #38.
Also a couple of optimizations.
There no official dependency for Ruby 1.9+ and it looks like 1.8 compatibility is obtained easily, although some tests would need tweaking because hashes in 1.8 are not ordered.