added fixes and comments