code clean up and docs update