improve resource closing on errors
Merge branch 'master' of https://github.com/davidpeklak/smt