Various fixes - mostly error/exception handling
fixed exception throwing