Creates variables and removes domains and variables that are not
needed