Fixed some bugs. And made some improvements.