Added addtional sphinx documentation and minor refactoring.