Fixes #26: Deal slightly better with caching; this will need a big refactor to do properly.