Cleaned up exception stuffs. Fixed many bugs.