Init with code from Wikibase.git

Used code from c809beca8f8da10ff0a4ee69d838fc0ac75b89fc.