Changed modify() API

Changed modify() API so that it takes either an Object or a Function.