Fixed issues that may cause crashes.