Submitted Version

Correct most bugs.