magic numbers removed. network error handling fixed.