Fix some of the type-related bugs introduced by my radical refactor

We have to ensure, that if we search using an integer key, we pass an integer