Many bug fixes and TODOs from code addressed.