fix 'lead' bug and general clean up