Fix some small bugs and style