Move compile mode expression to a mode hook