update code, add API to set main to avoid startup async hacks