added logging and fixed scripts to use it