fixed potential NULLptr problems and leaked objects when setting node metadata