First chunk of commenting and re-working
Gone through and adapted to more current coding standards