fix nimsapi/log and improve error handling