It would be nice to have a reference drawing about the setting parameters to know for example, the track separation how is it measured? from middle of each track, from inner side, from outer side?..and same goes for rest of parameter, this is to properly have the parts fitting together. I can figure it out just by looking on your calculation in the code, but it will be more helpful and straightforward if you provide it for future and ease of reference.
Thank you