Fixed settings issue. Fixed onclose cleanup