Fix relations and metadata loading