Original C implementation. Now abandoned.