Added compression and more pragmatic error handling.
Minor changes to be able to maintain a common 2 and 3 codebase.