Remove vendor-specific functions. Fixes #329
Port PRs #367, #389, #604, #656