fixes many bugs.