move encode dframe and add_id, closes #541
more refactoring
Merge pull request #547 from modilabs/refactor

Refactor