Refactor the IdHandler a bit