rebuild most of the functions