fixed some bugs and layout