Reduce number of children() and count() calls.
Avoid expensive array_key_exists() calls.
Merge branch 'improve-build-performance' into production

Conflicts:
	pirum