Updated image caching and first implementation of toDevice function