Some bug fixes and as well as adding in some debugging features