Fix code whitespace/formatting
Add null checks to getKey methods