Implement most script functionality.