made some partial changes, will finish later