Reorder checks, unwrap code
Merge pull request #437 from Dmitry-Me/reorderChecksUnwrapCode

Reorder checks, unwrap code