Fix memory leak when displaying bind list.

This also removes duplication from the code.