debug logging and State null fixed