Added some features and fixed some bugs.