merged PHerzig's changes