Made the wrappers more robust against segfaults and int<->real conversions.