Main Scratch data handling code imporvements