Added new APIs isEmpty, toArray and use them to make collection compatible to Template engine.