Some code can currently panic, it would be good to eliminate most/all of it through better error handling.