improved error handling
moved stream interface inside libcx9r