separate caching logic
adds limit option, closes #1