fix style and minor bugs