several bugfixes.
Merge origin/master