Fix a bug causing NullPointerException. Add null testing before using the database connection.
Merge remote-tracking branch 'origin/master'