Changes from different pull requests, and own fix