Fixed the logic of sending and handling of init and query messages
Merge remote-tracking branch 'origin/master'