LPS-34188

Hi Eduardo, I changed multiple things and added some comments in to the source to be verified. There were some bad pactices, so I fixed them, but maybe some parts of the code will not work.