Added some features. Fixed some bugs.