cleanup and reworking