Cleaned up the code, mostly.