That one patch + my own modifications

* Applied the patch submitted by someone into the original issue tracker of this project at Google Code
* Did some changes to the generated code, as required when strict compiler settings are being used in Eclipse
* Some miscellaneous refactorings