Bug fixes, minor tweaks