added lots of in-code documentation