removed several bugs