Misc. code cleanup and review