neatened, fixed some bugs