Refine clumsy code in elpa.