Improvements.

After Kun code review.