Minor fixes.

minor fixes to prevent crash.