allow arbitrary resulttype, fixes Xuewen's issue, and this stuff is going to get deeply refactored soon anyway.