Fixed many bugs.