Issue 508

I moved the duplicate Code from the both Build Generators into a helper, replaced some `in_array()` checks with `isset`. To make the script a little bit faster, I profiled the code on https://blackfire.io.

This should solve Issue #508.