Fix DB errors

Fix some DB errors being caused by $lastCheck being empty

Change-Id: I99f0d79b75aee1ad189a53ce0894a71ae87be4c7