Fix problems due to api change between 20 and 21