Finished flattening of type declarations, on to type checking, clock checking and flattening of expressions