General cleanup

Trying to combine code to reduce bugs. SMW temporarily broke, but it
seems due to two wrongs making a right.