Fixed some bugs and update engine