Refactor error handling a bit.
Use errors instead of panics in reflection code.