fix incorrect optional argument checking
fix incorrect resource destroy handling