ResourceMap: some refactors (use code instead of id) and implemented query