code cleanup

I did some code cleanup, to make testing easier.