Move code out of static#main into layout