Open
Description
The current code base pervasively uses unsafe code, especially to get mutable references from immutable reference/objects. This could include potential race condition and bugs. We should clean up the unsafe code to maximize the benefits of thread safety we can get from Rust's checks.
We should diagnose each of the unsafe cases, and categorize them: either 1) we need to use unsafe (mostly for performance reasons), or 2) we can refactor them into safe code. For 1), we should always encapsulate the unsafe code and make sure that they are correct.