Workaround for infinite loop on corrupted data
Exposed ot code publically and minor tweaks
Added registerType