Added template cloning capability

Please review this changes