Code cleanup, update doc