Implemented apply, and added the start of apply handling to the term factory.