better layout,removed redundant code,some minor bugfixes