Modernized code for ruby 1.9.3 and delayed jobs support

See commit messages for details. If you find my changes useful, please pull my changes, so the world can make use of them.

Thanks.
Tomas.