Added lots of debug output and debugged some constants