Adding some features from my PR