code clean up

house keeping, cleaned code and commented code