Better cache

fix #1006
fix #1007