Fixed crash bugs