Fix some minor bugs in general