This is the next approximation, a single patch against current git master.
Should cover all the features you asked. Please review it.
Benedek Laszlo