fixed performance issues && little cleanup