Adding debug massages and done some cleanup