cleanup and function updates