Fixed bug causing random crashes.