a few fixes, and make tab completion case insensitive
replace name_compare with lib function