improved log file writing to log all errors
use error_log function to write the log
cleaned up startup script