Pull request contains bug fixes and some improvement