Thanks for sharing!!
I just read the source code and I wonder if you have any reason for not using HLegder and the complimentary web-GUI..?
HLegder has a lot more features, and a community.
Completely understood if you just wanted to write your own fits-like-a-glove tool.