clean up code.

remove unnecessary vars, fix docs, add some missed var keywords