Bug fix and some style fixes.