many bugfix

From rosetta. I will push all rosetta code when I finished the R letter