Fixing some things, but script not yet running correctly, more fixes needed.