Some fixes and improvements

find this pull request for some fixes and improvements. Please review and merge. It would be nice to also close the coresponding issues in JIRA, there are severl (even old ones) open that are already fixed in the master.