code cleanup and fixes for the list 'command'