changed script name. Now Handles __name__. cleans external references like ([1]) from the output