fix source images, and add debug mode