reorganized base afui code