Provide better build details

Improve the build details:
 - refactor code (in preparation of proper reproducability)
 - log the command line
 - add the command line to the buildstats