Added null checks for bucket and objects.