The practice of giving criminals lighter sentences because of overcrowding and poor conditions in Western Australia's prisons should stop in most cases, the state's Court of Appeal rules.