Some minor fix. Added to_sql to Node class.
fixed scoping.