Add cloudstack migrations and some class refactoring