Bug fixes, small improvements