Cleaned up a bunch of code, made some fixes, etc