Layout work, fixing some bugs