Fixed potential bugs pertaining to wrapping native resources