Add mappings
Reorganize the code