DRYd code up a bit, fixed clearmap function