some changes done by ingebrigt