fixed a lot of minor bugs