Fixes for null object reference issues