relay: error handling and bugfix
minor changes