Code review comments.

  - removed needless nested function
  - fixed potential bug with mutable value of keyword argument.