Add comments and some enhancements.