improvements in the main srcipt