bug fixes in cursor positioning and wrapping cache invalidation.