style fixes

Here are some much needed style and bug fixes.