code clean up and style improvements