Made TargetWindow into a command. Streamlined script structure