Reworked value and distance code. Temp comments.