fix layout bugs and js exceptions