Refactored. Now support binary results.