Various fixes, tidying up, C++98 support

Removed need for C++11 union (non-POD data types), fixed various bugs,
added more try...catch handlers