c++-ification: 1) move all declarations into header 2) use const references 3) use unordered_map instead of map