Remember last path
Made code more thread-safe