NPE protection for empty query + removed unused IOutput