Fixed some misc. bugs