error handler and routing improvements