Minor refactor.

Be more consistent in variable naming.
Return more descriptive error.