Cleaned up code and added some more output.