(incomplete/untested) start converting main routine and tick handler