Refactor base internal query implementation, using fact signature for search