Addresed several TODOs and lots of code reviewing.
Fixed many miscellaneous faults.