Refractored code, incremental documentation update