Implemented caching of generated labels for Jobs.

There seems to be a bug in Jenkins 1.509.x that makes this operation a
significant bottleneck during queuing.

This also fixes some rare errors regarding labels not being inherited
correctly and improves the handling of the "magic" node testing label.
Basically, it will now only be added to the labels generated for a
build, if such a label is set at all.