Added code in preparation of format handling. Fails. Some fixes.