Fixed references and case errors