Cleanup, code re-organization