restructured some code, especially the maps