bug fixes, code clean up.