Yet another pullrequest

See commits for details, various improvements