Fixed error with passing register struct by value
More informative exception handling