cleanup and variable update