More clean up, refactor and documentation