Fixed cache behavior for view lookup

This fixes caching behavior related to issue #1089.
Also merged recent master changes into this branch.