core & ldr_*: redesign API and remove useless code