Fix availble-command-function related bugs