Cleaned up code, lots of small edits.