Switched to node iterator

And cleaned up calls and stupid checks. Also fixed a few minor bugs,
deprecated some functions no longer in use, improved comments, improved
variable names