Fix some style issues and some minor bugs I noticed at the same time