Removed unusued code, general code cleanup.

Also moved some code around and added author info.