[IMP] better exception handling + extra debug flag to print exception details