some bugfixes
Merge pull request #162 from andhieka/working

some bugfixes