code cleanup, updated doc