Improved workaround for gl(z) crashes in Ruby