Code cleanup and TODOs