Several changes & optimisations

Please check, it is updated from another module (node-red function)