Accounted for the directionless bug in 3dns. cleaned up code.