Better undefined check for adding anchor hashes
Slight mobile optimization