Moved generic logic to foreman core