Several minor fixes enhancements

Fixes for issues #36 #39 #40 and a few other minor serialize/deserialize bug fixes.