Merge event.cc into backend.cc

Move some VM related stuff into vm package.