Replace most TODOs

Also do minor reformatting.