Lots of changes. I'll try to make my commits more concise in the future.