minor changes for modularity

there are still a couple of bugs, i left comments to indicate.