Correction: the last commit was based on a wrong patch. Its now corrected.