Extract compilation stages into individual modules