Fix a few misc. bugs