Bug fixes, mainly