added more diagnostics to output, removed excess element from cost array