support setting (kbase) token for scripts as env variables 

along with some other bug fixes