Various bugfixing
Another (too) big commit ... :)