Move module header first for compiler enforced autonomy
Switch to using mostly shared pointers for exception safety

This removes the task of manually/explicitly disposing of memory
resources acquired during writeECLData().