addressed review comments and some cleanup of unused code