Table sorting fixes