Merged with Min-Kai's fork.