Simplify code complexity and better comments.