Updated SYNC command + added logout

Fixed issue #89, added logout to logic. Also fixed minor problem with
sync.