safer NS* <=> JS* conversion: checking for null pointers, etc.