bug fixes and additional debugging stuff