fix cleanup and add setting change handler