code clean up and some additions