remove optionals from plugin queries; refactor and consolidate