postMessage fix and some functions added