Fix bugs. Still need to be improved.