Did misc debugging.

Made progress, but not done yet.
Merged changes