Fix bug in encoding; tuple return; cleanup.