Fix two potential crashes