Added loads of debugging stuff