Ernie, read the Pronto IR Format documentation in the Files section by Barry Gordon. He does a great job of explaining the Sony format. Your code is so long as it is an unclean learn.
Try this and see if it works for you as well. Please report back the results.