Fixed bugs and TODOs