Issue39

Hi rafal, I just reviewed your proposal. I send you my remarks as a pull request. Only the first commit is an issue (minor). I didn't test at all (just compiled). Feel free to use or not. Regards.