Add error logging & debugging