Fixed some bugs, refined some features