bug fix, code clean up