Possible fix for #125, applied fixes from profi-concept's branch