integrated image cache. cleaned code.