Since a lot of changes had been made since this pull request
a "copy-paste" merge was easier than a nomral merge of the commit.

Thanks @c089 for the contribution.