Fixed a bug and added several debugging functions.