Massively reorganized things
fixed crash if logfile didn't exist