Code refinement

1. Reform data structure to modularize the code
2. Change the way vm_id is generated to achieve unique vm_id for each VM.