Code cleanup and documentation additions v2