some code cleanup, still requires more