Fixed some errors and bugs.