refactored metadata, cleaned up query, enabled filtering and ordering in query