Refactored assertNChildren functions to more general checkNChildren
(returning a Maybe).
Considerable refactoring of monads, data, and the error-handling routines.