better error msgs, bug fix
Merge branch '28-applydefine' into 29