code cleanup and streamlining