slight cleanup, still messy logic in add_child