Reorganize the code, add mappings
Remove dead code