Preload images in JS, remove some unused macros