Add bailouts and convert type errors to java exceptions.