code cleanup and stability