Documentation additions and major refactor