Include port number in term URLs

Closes #530.