Random fixes

Just small fixes I found while looking at the source code.

No change should alter behavior here.