Fix a few things here

I assume this file is still very much work-in-progress since it has so many issues.