more checks and some code reformating
Authored by: thibautd 2015-06-23
Parent: [r33529]
Child: [r33531]