Added more None checks and some default values when they fail.