Resolved critical bugs from scrutinizer

This resolves bugs marked critical according to:

https://scrutinizer-ci.com/g/erik-smit/librenms/inspections/c0930040-994c-4304-b15f-fc0d4b0157d8/issues/?status=new&selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=15&orderField=path&order=asc