fixed a memory leak in mode(); improved test for mode --KW