icmpd: improve ORM usage, fix some bugs