Update to latest version

Pull latests changes from upstream to improve compatibility