Caching window dimensions appears to improve performance.