Preserve line numbers, add return value type checks