Move code to scripts.
Fix a slight mistake...