Hi,
Please find the first version of the patch for review. I was not sure whatsome of the functions are used for and marked them with TODO.
CheersRam 4.0