Fixes for incorrect error signalling and to add automatic type casting of abstract to real types.