#542 fix

Take a look if some other functions need to be fixed too.