fix many bugs in application