adds caching. closes #1