first image optimizations and cleanup