fixed duplicate bug. some more cleanup