Feature/xmerl avoid undef rebased

Subsumes #706. This is #706 rebased and with 0079a4a908757714baebef70e538fea936d324a7 added.