Preparation scripts code improvements