Finished.. Unavoidable C bug found

This is as good as it's going to get. Read comments on the clamping
required.