bugfixes and reply to stefans first revision