cleanup and rework