Re-add validation; better error handling; fix callback variable scope problems