Fixes in scratch handling