Clean up code and update doc.