continued work on encode, and changed constants accordingly