code clean up and additional comments