More on refactoring and fix for null values