better dependencies for checkref
better mkdir for image, & debug logging