More work on conversion. Should have basic functionality (not tested)