light refactor + more info on alloc_id failure

Proof of concept for #50 (untested).