Reorganized the file and comments after another several hours of debugging and tracing