Bugfix and refactor of function getTableByPlayerId.