refactor

more logical arrangement, praam and comment cleanup