Many crash and bug fixes