improved error message, code cleanup.
Authored by: mrieser 2010-02-19
Parent: [r10516]
Child: [r10518]