Profile switching is now implemented properly.

This includes profile locking to avoid cases when two jobs trying to use the same rendertree with different profiles.