Fixed some small potential crashes.