added result/error constants, use constants where possible, determine type from destination address and switched to enum