Fix multiple minor bugs