Try to prevent the occasional ResourceWarning

Closes #28