merged in changes from Andreas