Debugging in a real environment - fixed some bugs