fix some layout bugs and core data bugs