Ideally we shouldn't even have to use a theme function anymore and this could all be done with a tableselect.