Completed port of nls() from nls.c to Java