Begin making things actually work

Added debugging code and improved commenting.