fixed several misc. bugs