Move metadata loading and visiblity judging to their own functions
Looks like that actually works...