Misc bug fixes
NPE Fixes