Minor cleanup, re-org code