script-engine work.
- Tidy up the code a bit