First attempt, based on vector example. Caching not working yet.