Fix logging and system state tracking