some fixes. merged with forked branch