pass in window first, then call
ref main properly
prior versions referenced old unused gen-code