code cleanup, improvements