some cleanup and commenting