qznc:
I made another iteration on your changes.http://codepad.org/9xB58cbE
I suggest to put your code on Rosettacode now, and then we'll do the changes there... As you see in other answers, both me and monarch_dodra have other ideas for improvements.
Bye, bearophile