Code cleaning :)

small bits of code cleaning.. please check the @todo remarks, probably bugs due to uninitialized vars.. membergroupsById() is a widely used function,