added default data to encode; added clear method