Galaxy formation and mergers with stars and massive black holes