I think the problem was due to something internal to BeautifulSoup. In essense, we were trying to add a BeautifulSoup object (such as contacttable) onto a string. This should have resulted in the BeautifulSoup object being turned into a string, then added to the "<td>" string.
In practise, something went awry, so I used str to force the BeautifulSoup object into a string. I'm not sure why the forcing was necessary, but it seems to have done the trick
