Code cleanup and additional comments where needed.