moved all data format conversion to formats.js + some tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
some testing an bugfixing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>