did small code improvements and added investigation comments