Read the from attribute from the main stanza, not the inside query. Also fixing another potential NULL pointer dereference.