Fixed potential crashes