FIX: better exception handling in FlexResourceStore, make sure underlying stream is closed