Cleaned up code mess.

Only minor stuff left.