Fixed crash bugs and make it stable