restructure runtime to allow different main