Cleanup node code, move into own module