Use localStorage for my trains (with fallback to cookie storage) and refactor jQuery events