fixed some fatal bugs.