Merge pull request #89 from tothfn/master

Several bugfixes