Fix bug with template replacement when moving outside of map before entering map for first time