Bugfix: don't reproduce intermediate targets unless targets that need to be updated depend on them. Also, cleaned up debugging lines a bit.