Fix for potential crashes