Fix some bugs. Still have some problems.