Fix collision between reading state on Master and writing - on device
Add some changes for debuggin