fix env
cleanup postmessage logic