Pre ref improvements

Organizational, style, and error message improvements. No changes to functionality.