It's a hack to get the slots count. If we can get OGS to print it, it would be simpler. Right now I use a "copy editor" to copy the current config to a file, then read the file and get the slots count.
Yes, it could be moved to a separate function.