Updated according to redmine issue 358