Bugfixes and program flow

#HOST-11 fixed