improved location saving, cleanup