added output caching, closes #3