Fixed many crash bugs

Fixed many crash bugs, it's stable now.