Fix global legend loading.

This was broken at some point during the DB interface change. It
looks like I started updating this and commited it accidentally
instead of finishing it. Can't find the commit though.