Distribution and Structure of Matter in and around Galaxies