code cleanup ready for build and readthedocs