Fixed multiple bugs

* Don't create JSON output with dependencies if the list of dependencies
is empty.

* Don't add the program multiple times by adding the program to the list
of dependencies inside the object for the program.

* When creating spawn environment use list of all files inclusive the
program itself and not just the dependencies.