Cleaned up dictionary lookup ajax endpoint

Also moved some functions around some