small bugs fixed and codes cleared up