added cache for img data, reorganized stuff to add features later