Making the writevmf code much prettier

Work in progress