Introducing Sync and Async query execution. Fixed problem with on-off state. General cleanup