Additinal fixes for resources not being released