added streamlined encoding routines