Cleanup and first impl of target writing