Major stability enhancements

The past few commits were not in tested well enough, and many were made
without syncing the changes from the others, which created a huge mess
that didn't even function. This is mostly cleaning up what was destroyed
in the last few commits.