Some error handling and more use cases support

Some changes needed to support new use cases