fixed handling of nil trunks

Might be slight overkill to do this as a PR, but this was interesting to me.