undo memory usage tuning and fix replaceplugin window size and tile masking