Various bug fixes

Bruno: rebased on your _road_to_linux branch and removed the wrong polar dirs patch. Please merge.