Merge some new functions from different forks.