Bug fix, bug discovery and TODOs added.