Fixes thanks to @swissmanu for review