Finish mapping, clean up code