Fixed critical bugs that double free cause it crashes always