added logging, tried to standardize when {}s were used on variables, and cleaned up the init output a bit
converted script to use internal functions rather, the old way was re-executing the script twice for restarts